﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utils;
using RegistrationController;

namespace HPMDesktop.Employee
{
    public partial class EmployeeData : Form
    {
        public EmployeeData()
        {
            InitializeComponent();
        }

        private void cmdSave_Click(object sender, EventArgs e)
        {
            bool result;
            EmployeeInfo objData = new EmployeeInfo();
            EmployeeInfo_Mapper objMapper = new EmployeeInfo_Mapper();

            try
            {
                objData.EmployeeId = Convert.ToString(txtEmployeeId.Text);
                objData.EmployeeType = Convert.ToString(txtEmployeeType.Text);
                objData.FName = Convert.ToString(txtFName.Text);
                objData.LName = Convert.ToString(txtLName.Text);
                objData.MobilePhone = Convert.ToString(txtMobilePhone.Text);
                objData.HomePhone = Convert.ToString(txtHomePhone.Text);
                objData.OfficePhone = Convert.ToString(txtOfficePhone.Text);
                objData.Email = Convert.ToString(txtEmail.Text);
                objData.Address1 = Convert.ToString(txtAddress1.Text);
                objData.Address2 = Convert.ToString(txtAddress2.Text);
                objData.City = Convert.ToString(txtCity.Text);
                objData.State = Convert.ToString(txtState.Text);
                objData.ZipCode = Convert.ToString(txtZipCode.Text);

                result = objMapper.Load_Employee_DATA(objData.EmployeeId, objData);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                objData.Dispose();
                objMapper.Dispose();

            }
        }

        private void EmployeeData_Load(object sender, EventArgs e)
        {
            string ID;

            //ID = Request.Form("ID");
            ID = "1";

            EmployeeInfo objData = new EmployeeInfo();
            EmployeeInfo_DataLoader objDataLoader = new EmployeeInfo_DataLoader();

            try
            {

                objData = objDataLoader.Get_Employee_DATA(ID);

                txtEmployeeId.Text = Convert.ToString(objData.EmployeeId);
                txtEmployeeType.Text = Convert.ToString(objData.EmployeeType);
                txtFName.Text = Convert.ToString(objData.FName);
                txtLName.Text = Convert.ToString(objData.LName);
                txtMobilePhone.Text = Convert.ToString(objData.MobilePhone);
                txtHomePhone.Text = Convert.ToString(objData.HomePhone);
                txtOfficePhone.Text = Convert.ToString(objData.OfficePhone);
                txtEmail.Text = Convert.ToString(objData.Email);
                txtAddress1.Text = Convert.ToString(objData.Address1);
                txtAddress2.Text = Convert.ToString(objData.Address2);
                txtCity.Text = Convert.ToString(objData.City);
                txtState.Text = Convert.ToString(objData.State);
                txtZipCode.Text = Convert.ToString(objData.ZipCode);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                objData.Dispose();
                objDataLoader.Dispose();

            }
        }

        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}

